Skip to content

Refactor OkHttp to use applyJavaModules() - #9633

Open
LouisLou2 wants to merge 1 commit into
lysine-dev:mainfrom
LouisLou2:issue-9103-kmp-java-modules
Open

Refactor OkHttp to use applyJavaModules() #9633
LouisLou2 wants to merge 1 commit into
lysine-dev:mainfrom
LouisLou2:issue-9103-kmp-java-modules

Conversation

@LouisLou2

Copy link
Copy Markdown

This extends applyJavaModules() to support KMP, preserving the existing multi-release JAR setup.

Closes #9103

Testing
Ran:

./gradlew :build-logic:spotlessCheck :okhttp:spotlessCheck :okhttp:jvmJar :module-tests:test -PokhttpModuleTests=true

@swankjesse swankjesse left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d prefer to hardcode all of these values to 9, cause that way searching for java9 turns up results. (We’re unlikely to have separate directories for other Java versions here)

}

from(compileJavaModuleInfo.map { it.destinationDirectory }) {
into("META-INF/versions/$javaModuleVersion/")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
into("META-INF/versions/$javaModuleVersion/")
into("META-INF/versions/9/")

tasks.register<JavaCompile>("compileJavaModuleInfo") {
val compileKotlinTask = tasks.getByName("compileKotlinJvm") as KotlinJvmCompile
val targetDir = compileKotlinTask.destinationDirectory.dir("../java$javaModuleVersion")
val sourceDir = file("src/jvmMain/java$javaModuleVersion")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val sourceDir = file("src/jvmMain/java$javaModuleVersion")
val sourceDir = file("src/jvmMain/java9")

val compileJavaModuleInfo =
tasks.register<JavaCompile>("compileJavaModuleInfo") {
val compileKotlinTask = tasks.getByName("compileKotlinJvm") as KotlinJvmCompile
val targetDir = compileKotlinTask.destinationDirectory.dir("../java$javaModuleVersion")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val targetDir = compileKotlinTask.destinationDirectory.dir("../java$javaModuleVersion")
val targetDir = compileKotlinTask.destinationDirectory.dir("../java9")

@LouisLou2
LouisLou2 force-pushed the issue-9103-kmp-java-modules branch from 461abe6 to e3aabfd Compare August 6, 2026 13:48
@LouisLou2

Copy link
Copy Markdown
Author

I’d prefer to hardcode all of these values to 9, cause that way searching for java9 turns up results. (We’re unlikely to have separate directories for other Java versions here)

@swankjesse Agreed. I've applied all three suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Gradle refactor applyJavaModules()

2 participants